<template>
  <div class="platform-echarts">
    <!-- 上面四个小图表 -->
    <div class="platform-up">
      <!-- 显示数字 -->
      <!-- 昨日新增用户数 -->
      <div class="platform-little">
        <div class="platform-title">
          <span>昨日新增用户数（人）</span>
          <span>®</span>
        </div>
        <div class="platform-content">
          <div>560</div>
          <div>
            <span>周同比<i>12%</i></span>
            <span>日同比<i>11%</i></span>
          </div>
        </div>
        <div class="platform-footer">
          <div>日均新增用户数<i>234</i></div>
        </div>
      </div>
      <!-- 昨日登陆用户数 -->
      <div class="platform-little">
        <div class="platform-title">
          <span>登录用户数（人）</span>
          <span>®</span>
        </div>
        <div class="platform-content">
          <div>8846</div>
          <div id="platform-echart3"></div>
        </div>
        <div class="platform-footer">
          <div>日访问量<i>234</i></div>
        </div>
      </div>
      <!-- 昨日交易额 -->
      <div class="platform-little">
        <div class="platform-title">
          <span>昨日交易额</span>
          <span>®</span>
        </div>
        <div class="platform-content">
          <div><i>￥</i>560</div>
          <div></div>
        </div>
        <div class="platform-footer">
          <div>转化率<i>234</i></div>
        </div>
      </div>
      <!-- 昨日支付笔数 -->
      <div class="platform-little">
        <div class="platform-title">
          <span>本周支付笔数</span>
          <span>®</span>
        </div>
        <div class="platform-content">
          <div>560</div>
          <div></div>
        </div>
        <div class="platform-footer">
          <div>昨日支付笔数<i>234</i></div>
        </div>
      </div>
    </div>
    <!-- 下面三个 图表 排名 -->
    <div class="platform-down">
      <!-- 一周销售额统计 -->
      <div class="platform-big">
        <div class="platform-title">
          <span>一周销售额统计</span>
        </div>
        <div class="platform-echart1" id="platform-echart1"></div>
      </div>
      <!-- 各个分类销售占比 -->
      <div class="platform-big">
        <div class="platform-title">
          <span>各个分类销售占比</span>
        </div>
        <div class="platform-echart2" id="platform-echart2"></div>
      </div>
      <!-- 店铺销量排行 -->
      <div class="platform-big">
        <div class="platform-title">
          <span>店铺销量排行</span>
        </div>
        <div class="platform-ranking-list">
          <ul>
            <li><span>白鹭岛1号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛2号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛3号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛4号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛5号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛6号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛7号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛8号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛9号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛10号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛11号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛12号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛13号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛14号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛15号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛1号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛2号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛3号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛4号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛5号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛6号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛7号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛8号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛9号店</span><span>12347,1523</span></li>
            <li><span>白鹭岛10号店</span><span>12347,1523</span></li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import * as echarts from "echarts";

export default {
  mounted() {
    this.drawecharts();
    this.lunbo();
    setInterval(this.lunbo, 10000);
  },
  methods: {
    drawecharts() {
      //获取元素
      var myChart1 = echarts.init(document.getElementById("platform-echart1"));
      var myChart2 = echarts.init(document.getElementById("platform-echart2"));
      var myChart3 = echarts.init(document.getElementById("platform-echart3"));
      //初始化图表并赋值
      //---------------------------柱状图------------------------
      myChart1.setOption({
        xAxis: {
          //x轴数据
          type: "category",
          data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
        },
        yAxis: {
          //y轴数据
          type: "value",
        },
        series: [
          {
            data: [120, 200, 150, 80, 70, 110, 130], //数据值
            type: "bar", //类型bar：柱状图
          },
        ],
      });
      //------------------------------饼图-----------------------------
      myChart2.setOption({
        legend: {
          //图例
          top: "bottom", //设置图例位于底部
        },
        series: [
          {
            name: "面积模式",
            type: "pie", //pie表示饼图
            radius: [25, 120], //饼图半径（内半径，外半径）   构成环形
            center: ["50%", "50%"], //饼图圆心位置
            roseType: "area", //展示成南丁格尔图   area：扇形圆心角相同，通过半径表示数据大小   radius：通过圆心角的大小，表示数据
            itemStyle: {
              borderRadius: 0, //图形边框圆角
            },
            data: [
              //数据和对应的值    图例信息取自这里面的name
              { value: 40, name: "rose 1" },
              { value: 38, name: "rose 2" },
              { value: 32, name: "rose 3" },
              { value: 30, name: "rose 4" },
              { value: 28, name: "rose 5" },
              { value: 26, name: "rose 6" },
              { value: 22, name: "rose 7" },
              { value: 18, name: "rose 8" },
            ],
          },
        ],
      });
      //-------------------------------折线图----------------------
      myChart3.setOption({
        grid: {               //图表距离dom元素边框的距离
          left: "2%",
          right: "2%",
          bottom: "2%",
          top:"0%"
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            show: false,
          },
        ],
        yAxis: [
          {
            type: "value",
            show: false,
          },
        ],
        series: [
          {
            name: "Line",
            type: "line",
            stack: "总量",
            smooth: true,           //设置折线为平滑
            lineStyle: {
              width: 0,
            },
            showSymbol: false,
            areaStyle: {              //颜色渐变
              opacity: 0.8,
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: "rgba(0, 221, 255)",
                },
                {
                  offset: 1,
                  color: "rgba(77, 119, 255)",
                },
              ]),
            },
            emphasis: {
              focus: "series",
            },                                            //数值
            data: [120, 282, 111, 234, 220, 340, 120],
          },
        ],
      });
    },
    //-------------------------------轮播图----------------------------
    lunbo() {
      $(".platform-ranking-list ul").animate(
        {
          //利用jquery的animate方法实现轮播图
          top: -525,
        },
        10000,
        "linear",
        function () {
          $(".platform-ranking-list ul").css("top", 0);
        }
      );
    },
  },
};
</script>
<style lang="less">
.platform-echarts {
  width: 100%;
  height: 620px;
}
.platform-up {
  display: flex;
}
.platform-little {
  flex: 1;
  height: 200px;
  margin: 10px;
  background-color: white;
}
.platform-little:nth-child(2) {
  margin-left: 0;
}
.platform-little:nth-child(3) {
  margin-left: 0;
}
.platform-little:nth-child(4) {
  margin-left: 0;
}
.platform-title {
  height: 50px;
  line-height: 50px;
  margin-left: 20px;
  margin-right: 20px;
}
.platform-title span:nth-child(1) {
  float: left;
  font-size: 16px;
  color: rgb(143, 142, 142);
}
.platform-title span:nth-child(2) {
  float: right;
  font-size: 20px;
  color: rgb(143, 142, 142);
}
.platform-content {
  margin-left: 20px;
  margin-right: 20px;
  height: 100px;
}
.platform-content div:nth-child(1) {
  height: 60px;
  line-height: 60px;
  font-size: 30px;
  font-weight: bolder;
  margin-left: 20px;
}
.platform-content div:nth-child(2) {
  height: 40px;
  line-height: 40px;
  color: rgb(143, 142, 142);
}

.platform-content i {
  font-style: normal;
  margin-left: 20px;
}
.platform-content div:nth-child(2) span:nth-child(2) {
  margin-left: 30px;
}
.platform-footer {
  margin-left: 20px;
  margin-right: 20px;
  height: 50px;
  line-height: 50px;
  color: rgb(143, 142, 142);

  position: relative;
}
.platform-footer::before {
  content: "";
  width: 100%;
  height: 2px;
  position: absolute;
  background-color: rgb(143, 142, 142);
  top: 0;
}
.platform-footer i {
  font-style: normal;
  margin-left: 20px;
}
.platform-down {
  display: flex;
}
.platform-big {
  height: 400px;
  margin-left: 10px;
  background-color: #fff;
}
.platform-big:nth-child(1) {
  flex: 3;
}
.platform-big:nth-child(2) {
  flex: 3;
}
.platform-big:nth-child(3) {
  flex: 2;
  margin-right: 10px;
}
.platform-big .platform-title {
  position: relative;
}
.platform-big .platform-title::before {
  content: "";
  width: 100%;
  height: 2px;
  background-color: rgb(143, 142, 142);
  position: absolute;
  top: 50px;
}
.platform-echart1 {
  width: 100%;
  height: 350px;
}
.platform-echart2 {
  width: 100%;
  height: 350px;
}
.platform-ranking-list {
  width: 100%;
  height: 350px;
  position: relative;
  overflow: hidden;
}
.platform-ranking-list ul {
  top: 0;
  position: absolute;
  width: 100%;
  padding-left: 0;
}
.platform-ranking-list ul li {
  width: 100%;
  height: 35px;
  line-height: 35px;
  list-style: none;
}
.platform-ranking-list ul li:hover {
  background-color: rgb(84, 112, 198);
}
.platform-ranking-list ul li span:nth-child(1) {
  float: left;
  margin-left: 30px;
}
.platform-ranking-list ul li span:nth-child(2) {
  float: right;
  margin-right: 30px;
}

</style>
